<#include "/common/head.html"/>

 <div id="zcurdHeadTable" class="easyui-panel" data-options="fit:true,border:false,novalidate:true">
    <div style="padding:0px">
    <form class="easyui-form" id="ff" method="post" data-options="novalidate:true">
        <table cellpadding="5" width="100%">
        	<#assign columnSize=head.dialog_size?split("x")[0]?number />
        	<#if columnSize lt 500>
        		<#assign columnSize=1 />
        	<#elseif columnSize gte 500 && columnSize lt 800 >
       			<#assign columnSize=2 />
        	<#else>
        		<#assign columnSize=3 />
        	</#if>
        	
           	<#list addFieldList as item>
           		<#assign easyui_type="easyui-textbox" />
	        	<#if item.data_type=='timestamp' || item.data_type=='datetime' || item.data_type=='date'>
	        		<#assign easyui_type="easyui-datebox" />
        		</#if>
        		
           		<#if item_index == 0 || (item_index + 0) % columnSize == 0>
            <tr>
           		</#if>
           		<th><span>${item.column_name}：</span></th>
               	<td>
               		<#if item.dict??>
	            		<input class="easyui-combobox" name="${item.field_name}" value="${queryPara[item.field_name!]!}" style="width:130px" data-options="
	            				valueField: 'id',
   								textField: 'text',
	            				data: [
	            					{id:'', text:''}
	            					<#list item.dict.keySet() as key>
	            					,{id:${key}, text:'${item.dict.get(key)}'}
			            			</#list>
	            				]
	            				<#if item.is_allow_null==0>,required:true</#if>
	            			" />        	
			        <#elseif item.data_type=='text'>
			        	<textarea name="${item.field_name}" data-options="<#if item.is_allow_null==0>required:true</#if>" rows="" cols="" style="width: 130px;"></textarea>
			        <#else>
               			<input class="${easyui_type}" type="text" name="${item.field_name}" value="${queryPara[item.field_name!]!}" data-options="<#if item.is_allow_null==0>required:true</#if>" style="width: 130px;"></input>
			        </#if>
           		</td>
           		
           		<#if item_index != 0 && (item_index + 1) % columnSize == 0>
            </tr>
           		</#if>
           	</#list>
           	<#if addFieldList.size() % 3 != 0>
           		<#if (3 - addFieldList.size() % columnSize) == 1>
                <td></td>
	           	</#if>
	           	<#if (3 - addFieldList.size() % columnSize) == 2>
                <td></td>
                <td></td>
	           	</#if>
            </tr>
           	</#if>
        </table>
    </form>
    </div>
</div>
<script>
top.window.subPage.save = save;
function save(successFunc) {
	if($("#ff").form('enableValidation').form('validate')) {
		$.post("add", getParam(), function(data) {
			if(successFunc) {
				successFunc();
			}
			top.window.closeWindow();
			top.window.subPage.loadCurrDatagrid();
		});
	}
}
function getParam() {
	var param = {
	    "headId": ${headId}, 
		<#list addFieldList as item>
       	    "model.${item.field_name}": $(":input[name='${item.field_name}']").val()<#if addFieldList.size()!=item_index>, </#if>
		</#list>
	}
	for(key in param) {
		if(!param[key]) {
			delete param[key];
		}
	}
	return param;
}

//扩展js
<#list jsList as item>
	<#if item.page == "add">
${item.js_content!};
	</#if>
</#list>
</script>
<#include "/common/foot.html"/>